import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { MergeInfo } from "./info/MergeInfo";
import { EMergeType } from "../../../Message/Public/EMergeType";
type int = number;
//class MergeConfig
    
    export  class MergeConfig
    {
        constructor()
        {
            
            this._mountFactor = new Map<any, any> /* flash.utils.Dictionary */();
            this._fashionDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._weapFashionDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._wingDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._footPrintDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._bubbleDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._surroundDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._waistBeltDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._elfDic = new Map<any, any> /* flash.utils.Dictionary */();
            if (MergeConfig._instance != null) 
            {
                throw new Error(" MergeConfig 单例 ");
            }
            this.init();
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_merge_config.json");
            this.writeUpdate(loc1);
            return;
        }

        /* internal  */writeUpdate(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new MergeInfo();
                loc1.color = loc2.color;
                loc1.factor = loc2.factor;
                loc1.type = loc2.type;
                if (loc1.type == EMergeType._EMergeTypeMount) 
                {
                    this._mountFactor[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeFashion) 
                {
                    this._fashionDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeWeaponFashion) 
                {
                    this._weapFashionDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeWing) 
                {
                    this._wingDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeFootprint) 
                {
                    this._footPrintDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeBubble) 
                {
                    this._bubbleDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeSurround) 
                {
                    this._surroundDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type == EMergeType._EMergeTypeWaistBelt) 
                {
                    this._waistBeltDic[loc1.color] = loc1.factor;
                    continue;
                }
                if (loc1.type != EMergeType._EMergeTypeElf) 
                {
                    continue;
                }
                this._elfDic[loc1.color] = loc1.factor;
            }
            return;
        }

        public getMountFactor(arg1: int): number
        {
            return this._mountFactor[arg1];
        }

        public getFactorByType(arg1: int, arg2: int): number
        {
            var loc1=0;
            if (arg1 != EMergeType._EMergeTypeFashion) 
            {
                if (arg1 != EMergeType._EMergeTypeWeaponFashion) 
                {
                    if (arg1 != EMergeType._EMergeTypeWing) 
                    {
                        if (arg1 != EMergeType._EMergeTypeFootprint) 
                        {
                            if (arg1 != EMergeType._EMergeTypeBubble) 
                            {
                                if (arg1 != EMergeType._EMergeTypeSurround) 
                                {
                                    if (arg1 != EMergeType._EMergeTypeWaistBelt) 
                                    {
                                        if (arg1 == EMergeType._EMergeTypeElf) 
                                        {
                                            loc1 = this._elfDic[arg2];
                                        }
                                    }
                                    else 
                                    {
                                        loc1 = this._waistBeltDic[arg2];
                                    }
                                }
                                else 
                                {
                                    loc1 = this._surroundDic[arg2];
                                }
                            }
                            else 
                            {
                                loc1 = this._bubbleDic[arg2];
                            }
                        }
                        else 
                        {
                            loc1 = this._footPrintDic[arg2];
                        }
                    }
                    else 
                    {
                        loc1 = this._wingDic[arg2];
                    }
                }
                else 
                {
                    loc1 = this._weapFashionDic[arg2];
                }
            }
            else 
            {
                loc1 = this._fashionDic[arg2];
            }
            return loc1;
        }

        public static get instance(): MergeConfig
        {
            if (MergeConfig._instance == null) 
            {
                MergeConfig._instance = new MergeConfig();
            }
            return MergeConfig._instance;
        }

        /* internal */ /* var */_mountFactor: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_fashionDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_weapFashionDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_wingDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_footPrintDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_bubbleDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_surroundDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_waistBeltDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_elfDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: MergeConfig;
    }
